package com.xu.sys.service.impl;

import com.xu.sys.bean.SysUser;
import com.xu.sys.dao.IUserDao;
import com.xu.sys.dao.impl.UserDaoImpl;
import com.xu.sys.service.IUserService;
import com.xu.sys.utils.PageUtils;

import java.util.List;
/**
 * 系统用户
 * 业务处理的接口定义
 */
public class IUserServiceimpl implements IUserService {
    private IUserDao dao = new UserDaoImpl();

    @Override
    public List<SysUser> list(SysUser user) {
        return dao.list(user);
    }

    @Override
    public int save(SysUser user) {
        return dao.save(user);
    }

    @Override
    public SysUser findById(int id) {
        return dao.findById(id);
    }

    @Override
    public int updteById(SysUser user) {
        return dao.updteById(user);
    }

    @Override
    public int deleteById(int id) {
        return dao.deleteById(id);
    }

    @Override
    public void listPage(PageUtils pageUtils) {
       List<SysUser> list = dao.listPage(pageUtils);
       int count = dao.count(pageUtils);
        // 封装分页的数据
        pageUtils.setList(list);
        pageUtils.setTotalCount(count);

    }

    @Override
    public int count(PageUtils pageUtils) {
        return dao.count(pageUtils);
    }

    @Override
    public SysUser findByName(String userName) {
        List<SysUser> list  =dao.findByName(userName);
        return list != null && list.size() > 0 ? list.get(0):null;
    }



}
